package com.minimoment.base;

import com.minimoment.model.domain.*;
import com.minimoment.model.service.*;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
import org.apache.struts2.interceptor.SessionAware;
import org.springframework.beans.factory.annotation.Autowired;

import java.lang.reflect.ParameterizedType;
import java.util.List;
import java.util.Map;

/**
 * Created by etund on 2014/10/30.
 */
public abstract class BaseAction<T>extends ActionSupport implements ModelDriven<T>,SessionAware {
    protected List<MovieNews> movieNewses;
    protected List<Movie> movies;
    protected List<UMcomemt> umComents;
    protected List<Area> areas;
    protected List<Theater> theaters;
    protected List<Telecine> telecines;
    protected List<Screenings> screeningses;
    protected  Map<String ,Object> session;
    @Autowired
    protected ScreeningsService screeningsService;
    @Autowired
    protected TelecineService telecineService;
    @Autowired
    protected  AreaService areaService;
    @Autowired
    protected MovieNewsService movieNewsService;
    @Autowired
    protected UMcomentService umComentService;
    @Autowired
    protected MovieService movieService;
    @Autowired
    protected UserService userService;
    @Autowired
    protected TheaterService theaterService;
    protected   T model;

    public BaseAction() {
        try {
            ParameterizedType pt = (ParameterizedType)this.getClass().getGenericSuperclass();
            Class<T> clazz = (Class<T>)pt.getActualTypeArguments()[0];
            model = clazz.newInstance();
        }catch (Exception e){
            throw new RuntimeException(e);
        }
    }
    @Override
    public T getModel() {
        System.out.println("==============getModel==============");
        return model;
    }

    @Override
    public void setSession(Map<String, Object> session) {
                this.session = session;
    }

    public List<Telecine> getTelecines() {
        return telecines;
    }

    public void setTelecines(List<Telecine> telecines) {
        this.telecines = telecines;
    }

    public List<MovieNews> getMovieNewses() {
        return movieNewses;
    }

    public void setMovieNewses(List<MovieNews> movieNewses) {
        this.movieNewses = movieNewses;
    }

    public List<Movie> getMovies() {
        return movies;
    }

    public void setMovies(List<Movie> movies) {
        this.movies = movies;
    }

    public List<UMcomemt> getUmComents() {
        return umComents;
    }

    public void setUmComents(List<UMcomemt> umComents) {
        this.umComents = umComents;
    }

    public List<Area> getAreas() {
        return areas;
    }

    public void setAreas(List<Area> areas) {
        this.areas = areas;
    }

    public List<Theater> getTheaters() {
        return theaters;
    }

    public void setTheaters(List<Theater> theaters) {
        this.theaters = theaters;
    }
}

